﻿using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApp4
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // 假设我们要将 button1 上的一个点转换为相对于 button2 的点
            Point pointRelativeToButton1 = new Point(0, 0);
            Point pointRelativeToButton2 = button1.TranslatePoint(pointRelativeToButton1, MainGrid);
            // 输出转换后的点的坐标
            MessageBox.Show($"Translated Point: X={pointRelativeToButton2.X}, Y={pointRelativeToButton2.Y}");
        }
    }
}